#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <memory>

using namespace std;

int main(int argc, char* argv[]) {

    int* p = new int(10);
    *p = 20;
    cout <<"*p = "<< *p << endl;
    shared_ptr<int> q(new int(*p));
    cout <<"q = "<< *q << endl;
    
    q.reset();
    // {
    //     unique_ptr<int> p(new int(10));
    //     // shared_ptr<int> p(new int(10));
    //     cout << "p: " << *p << endl;
    //     cout<<"1.Address of p: "<<p.get()<<endl;
    //     // cout<<"1.Number of references to p: "<<p.use_count()<<endl;
    //     p.reset(new int(20));
    //     auto q = move(p);
    //     cout << "q: " << *q << endl;
    //     cout<<"2.Address of q: "<<q.get()<<endl;
    //     // p.reset();   
    //     if(p==nullptr){
    //         cout<<"p is nullptr"<<endl;
    //         exit(0);
    //     }
    //     cout << "p: " << *p << endl;
    //     cout<<"2.Address of p: "<<p.get()<<endl;
    //     // cout<<"2.Number of references to p: "<<p.use_count()<<endl;
    // }

    return 0;
}